import type { Request, ResponseToolkit } from "@hapi/hapi";
import Hapi from "@hapi/hapi";
import { TempalteCate } from "../../model/index";

let route: Hapi.ServerRoute<Hapi.ReqRefDefaults> = {
  path: "/getTemList",
  method: "get",
  handler: async (r: any, h: ResponseToolkit) => {
    try {
      const templateList: any = await TempalteCate.findOne({
        _id: r.query.id,
      })
        .select("id")
        .populate("temList");
      return { code: 200, data: templateList.temList };
    } catch (err: any) {
      console.log(err, "err");
      return err;
    }
  },
  options: {
    plugins: {
      "hapi-swagger": {
        security: [{ apiKey: [] }],
      },
    },
    tags: ["api"],
  },
};
export default route;
